<?php 
	Class Hotel extends CI_Controller{
		public function __construct(){
			parent::__construct();
			$this->load->model("model_package");
			$this->load->model("model_hotel");
			$this->load->model("model_hotelreview");
			$this->load->model("model_hotelroom");
			$this->load->model("model_hotelroomprice");
			$this->load->model("model_restaurant");
			$this->load->model("model_activity");
			$this->load->model("model_flight");
			$this->load->model("model_car");
			$this->load->model("model_guild");
			$this->load->model("model_hotelbanner");
		}
		
		public function detail($idhotel){
			if(isset($idhotel)){
				$mydate=getdate(date("U"));
				$datetime= $mydate['year']."-".$mydate['mon']."-".$mydate['mday'];
				$data["hotel"]=$this->model_hotel->getdata(intval($idhotel));				
				$data['similar']=$this->model_hotel->gettopbyid($data['hotel']['id'],$data['hotel']['provide'],$data['hotel']['star'],3,0);				
				$data['roomofhotel']=$this->model_hotelroom->getbyhotelid($idhotel,$_GET['from']);
				foreach($data['roomofhotel'] as $key=>&$v){					
					if($v['minprice']==NULL){
						unset($data['roomofhotel'][$key]);	
					}
				}
				$data['banner']=$this->model_hotelbanner->getallbyhotelid(intval($idhotel));		
			}
			
			$data['idhotel']=intval($idhotel);
			$data["restaurant"]=$this->model_restaurant->gettopByprovide_status($data['hotel']['provide'],0,6,0);
			$data["activities"]=$this->model_activity->gettopByprovide_status($data['hotel']['provide'],0,6,0);
			$data["package"]=$this->model_package->gettopByprovide_status($data['hotel']['provide'],0,6,0);
			$data["flight"]=$this->model_flight->gettopByprovide_status($data['hotel']['provide'],0,6,0);
			$data["car"]=$this->model_car->gettopByprovide_status($data['hotel']['provide'],0,3,0);
			$data["guide"]=$this->model_guild->gettopByprovide_status($data['hotel']['provide'],0,3,0);
			$data['listname_restaurant']=$this->model_restaurant->listall_name();
			
			$data["template"]="hotel/hotel_detail";
			$this->load->view("layout",$data);
		}
		
		public function hotel_search_result(){
			if(isset($_GET["provide"]) && isset($_GET['from'])){	
				$data["total"]=$this->model_hotel->get_search_ajax($_GET['provide'],$_GET['from'],'','','','price','',10000000000,0);
				$data["data"]=$this->model_hotel->get_search_ajax($_GET['provide'],$_GET['from'],'','','','price','',10,0);
				$data['name']=$this->model_hotel->get_all_name();
				$data['listbanner']=array();
				if(count($data['data'])>0){
					foreach($data['data'] as $key=>&$v){					
						if($v['minprice']==NULL){
							unset($data['data'][$key]);	
						}
						
					}
					foreach($data['total'] as $key=>&$v){
						if($v['minprice']==NULL){
							unset($data['total'][$key]);	
						}		
					}
					foreach($data['data'] as &$listbanner){					
						$data['listbanner'][]=$this->model_hotelbanner->gettopbanner_search(intval($listbanner['id']));
					}
				}
			}
			$data['listname_restaurant']=$this->model_restaurant->listall_name();
			
			$data["template"]="hotel/hotel_search_result";
			$this->load->view("layout",$data);
		}

  		public function hotelinmyanmar(){
			$data['yangon']=$this->model_hotel->countallhotelbyprovide('yangon');
			$data['mandalay']=$this->model_hotel->countallhotelbyprovide('mandalay');
			$data['inle']=$this->model_hotel->countallhotelbyprovide('inle');
			$data['bagan']=$this->model_hotel->countallhotelbyprovide('bagan');
			
			$data['listname_restaurant']=$this->model_restaurant->listall_name();
			$data["template"]="hotel/myanmar";
			$this->load->view("layout",$data);	
		}
	}
?>